setContentCaptureSession

Sets the (optional) ContentCaptureSession associated with this view.

This method should be called when you need to associate a ContentCaptureContext to the content capture events associated with this view or its view hierarchy (if it's a ViewGroup).

For example, if your activity is associated with a web domain, first you would need to set the context for the main DOM:

  ContentCaptureSession mainSession = rootView.getContentCaptureSession();
  mainSession.setContentCaptureContext(ContentCaptureContext.forLocusId(Uri.parse(myUrl));

Then if the page had an IFRAME, you would create a new session for it:

  ContentCaptureSession iframeSession = mainSession.createContentCaptureSession(
      ContentCaptureContext.forLocusId(Uri.parse(iframeUrl)));
  iframeView.setContentCaptureSession(iframeSession);
Compatibility behavior:
  • SDK 29 and above, this method matches platform behavior.
  • SDK 28 and below, this method does nothing.

Parameters

v

The View against which to invoke the method.

contentCaptureSession

a session created by createContentCaptureSession.